import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/*
 * Tạo ứng dụng GUI đầu tiên sử dung Swing
 * */
public class frmMain {

	private JFrame frame;
	private JTextField txtHoten;
	private JLabel lbXinChao;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frmMain window = new frmMain();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public frmMain() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 336, 173);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JLabel lb1 = new JLabel("Xin ch\u00E0o");
		lb1.setBounds(26, 12, 67, 14);
		frame.getContentPane().add(lb1);
		
		lbXinChao = new JLabel("Xin ch\u00E0o b\u1EA1n: ");
		lbXinChao.setBounds(26, 90, 203, 23);
		frame.getContentPane().add(lbXinChao);
		txtHoten = new JTextField();
		txtHoten.setBounds(103, 9, 168, 20);
		frame.getContentPane().add(txtHoten);
		txtHoten.setColumns(10);
		
		JButton btnNewButton = new JButton("OK");
		btnNewButton.setBounds(154, 41, 75, 23);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String hoten = txtHoten.getText();
				lbXinChao.setText("Xin chào bạn: " + hoten);
			}
		});
		frame.getContentPane().add(btnNewButton);
	}
}
